package com.yeyks.controller.user;

import com.google.common.collect.Maps;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.dto.UserMemberCardWebDTO;
import com.yeyks.common.param.UserMemberCardQueryParam;
import com.yeyks.commonReference.service.consumer.UserMemberCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @author: dagny
 * @date: 2019/12/23 0023 10:45
 */
@Api(tags = "V3.8.2会员管理")
@Slf4j
@RestController
@RequestMapping(value = "/user/card")
public class UserMemberCardWebController {

    @Autowired
    private UserMemberCardService userMemberCardService;

    @ApiOperation("分页查询会员")
    @PostMapping("/query")
    public AjaxResponseBody queryList(@Validated UserMemberCardQueryParam param){

        AjaxResponseBody body = null;
        List<UserMemberCardWebDTO> userMemberCardDTOList = userMemberCardService.queryByParam(param);
        int count = userMemberCardService.queryCount(param);
        HashMap<String, Object> map = Maps.newHashMap();
        map.put("count", count);
        map.put("list", userMemberCardDTOList);
        body = AjaxResponseBody.success(map);
        return body;
    }
}
